<template>
	<z-paging ref="paging" v-model="list" @query="getOrderList" empty-view-text="暂无推广明细"
		empty-view-img="/static/image/order-empty.png" :empty-view-img-style="{width:'150rpx',height:'150rpx'}"
		:empty-view-title-style="{marginTop: '30rpx'}">
		<template #refresher="{refresherStatus}">
			<!-- 此处的custom-refresh为demo中自定义的组件，非z-paging的内置组件，请在实际项目中自行创建。这里插入什么view，下拉刷新就显示什么view -->
			<custom-refresher :status="refresherStatus" />
		</template>
		<view class="list-box pad-30" v-if="list.length > 0">
			<view class="list pad-30 bg-white radius30 mar-bottom-30" v-for="item in list" :key="item.id">
				<view class="address font-30 font-w-500">{{item.title}}</view>
				<view class="mar-top-30 font-28 color-646464">
					用户名：{{item.nickname}}
				</view>
				<view class="mar-top-30 font-28 color-646464">
					注册时间：{{timeFormat(item.reg_at, 'yyyy-mm-dd hh:MM')}}
				</view>
			</view>
		</view>
	</z-paging>
</template>

<script setup>
	import { ref, reactive } from 'vue';
	import { childPageList } from '@/api/index.js';
	import { onLoad, onShow, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app';
	import util from '@/util/share.js'
	import { dataReportFun } from '@/util/dataReport.js'
	import { timeFormat, } from '@/node_modules/uview-plus';

	onLoad((option) => {
		dataReportFun({
			event: "client.page_view",
		})
		util.friends();
	});

	const list = ref([]);
	const paging = ref(null);
	const getOrderList = (page, pageSize) => {
		childPageList({
			page,
			ps: pageSize
		}).then(res => {
			if (res?.code == 200) {
				paging.value.complete(res.data.data);
			} else {
				paging.value.complete(false);
			}
		})
	}

	// 分享
	onShareAppMessage(() => {
		return util.onShare({
			path: `/pages/index/index`
		})
	})

	onShareTimeline(() => {
		let uid = "";
		if (uni.getStorageSync('userId')) {
			uid = uni.getStorageSync('userId');
		}
		let imageUrl = uni.getStorageSync('shareCover');
			
		return {
			query: `uid=${uid}&ref=wxmini_user_share`,
			title: "心宇利家政",
			imageUrl: imageUrl
		}
	})
</script>

<style scoped lang="scss">
	.list-box {
		background: #F4F6F8;
	}
</style>